#include <iostream>
#include <vector>

using namespace std;

template <class InputIterator, class T>
InputIterator find_custom(InputIterator first, InputIterator last,
                          const T &value) {
  while (first != last && *first != value)
    ++first;
  return first;
}

template <class InputIterator, class Function>
Function for_each_custom(InputIterator first, InputIterator last, Function f) {
  for (; first != last; ++first)
    f(*first);
  return f;
}

int main() {
  vector<int> v = {1, 2, 3, 4, 5};
  auto it = find_custom(v.begin(), v.end(), 3);
  if (it != v.end())
    cout << "Found " << *it << endl;
  else
    cout << "Not found" << endl;

  for_each_custom(v.begin(), v.end(), [](int x) { cout << x << " "; });
  cout << endl;

  return 0;
}